install :
	python setup.py install

initial_data : \
shotserver05/platforms/fixtures/initial_data.json \
shotserver05/browsers/fixtures/initial_data.json \

shotserver05/%/fixtures/initial_data.json :
	mkdir -p shotserver05/$*/fixtures
	shotserver05/manage.py dumpdata --indent=4 $* > $@

docs : \
docs/xml-rpc.txt \

docs/xml-rpc.txt :
	xmlrpcdoc http://127.0.0.1:8000/xmlrpc/ > $@

docs/html : docs
	mkdir -p $@
	ls docs | grep txt | sed s/.txt// \
	| xargs -Iname rst2html.py docs/name.txt docs/html/name.html

sorted : docs
	cat docs/xml-rpc.txt | sort -u > sorted/docs-xml-rpc.txt
	grep -hv '__ =' shotserver05/*/admin.py | sort -u > sorted/admin.txt
	grep -hv '__ =' shotserver05/*/forms.py | sort -u > sorted/forms.txt
	grep -hv '__ =' shotserver05/*/models.py | sort -u > sorted/models.txt
	grep -hv '__ =' shotserver05/*/urls.py | sort -u > sorted/urls.txt
	grep -hv '__ =' shotserver05/*/views.py | sort -u > sorted/views.txt
	grep -hv '__ =' shotserver05/*/xmlrpc.py | sort -u > sorted/xmlrpc.txt
	grep -hv '__ =' shotserver05/*/tests.py | sort -u > sorted/tests.txt

headers :
	find . -name "*.py" | grep -v build/ \
	| xargs header.py shotserver05/__init__.py

properties :
	find . -name "*.py" \
	| grep -v build/ \
	| xargs svn propset svn:keywords "Rev Date Author"
	find . -type f | grep -v build/ | grep -v \\.svn \
	| grep -v \\.bz2 | grep -v \\.gz | grep -v \\.pyc \
	| grep -v \\.png | grep -v \\.ico | grep -v \\.jpg \
	| grep -v django.mo | grep -v rosetta-shotserver \
	| xargs svn propset svn:eol-style native

pep8 :
	pep8.py --filename=*.py shotserver05

pylint :
	-pylint shotserver05 \
	| grep -v "Relative import 'se" \
	| grep -v 'Invalid name "urlpatterns"' \
	| grep -v "Unused import deseb" \
	| grep -v "Inline] Missing docstring" \
	| grep -v "Admin] Missing docstring" \
	| grep -v "Meta] Missing docstring" \
	| grep -v "Meta] Class has no __init__ method" \
	| grep -v "Meta] Too few public methods" \
	| grep -vi "Wildcard import" \
	| grep -v "has no 'objects' member" \
	| grep -v "Unused argument 'request'" \
	| grep -v "_meta" \
	| grep -v /tests.py:

jquery :
	wget -O shotserver05/static/js/jquery.form.js \
http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js
	wget -O shotserver05/static/js/jquery.js \
http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js
#http://jqueryjs.googlecode.com/files/jquery-1.2.6.js
#http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js

# You need to start the test server first, in a separate shell:
# manage.py testserver authtestdata
xmlrpc : xmlrpc-system xmlrpc-factory xmlrpc-screen xmlrpc-browsers
	@echo Polling the server for a matching job...
	tools/xmlrpc.py factories.listActiveFactories | grep "\[\]"
	rm -f testclient.html testfactory.html
#	tools/xmlrpc.py --auth=testfactory.html jobs.poll testfactory
#	tools/xmlrpc.py factories.listActiveFactories | grep testfactory

xmlrpc-system :
	@echo XML-RPC introspection...
	tools/xmlrpc.py system.listMethods | grep methodHelp
	tools/xmlrpc.py system.methodHelp system.methodHelp | grep Arguments
	tools/xmlrpc.py system.methodSignature system.methodHelp | grep string

xmlrpc-factory : testclient.html
	@echo Creating screenshot factory...
	tools/xmlrpc.py platforms.operatingSystemDetails leopard | grep Leo
	tools/xmlrpc.py factories.factoryDetails testfactory | grep 404
	tools/xmlrpc.py --auth=testclient.html factories.createFactory \
	testclient testfactory leopard MacBook
	tools/xmlrpc.py factories.factoryDetails testfactory | grep leopard

xmlrpc-screen : testclient.html
	@echo Adding screen sizes and color depths...
	tools/xmlrpc.py --auth=testclient.html factories.addScreenSize \
	testclient testfactory 800 600
	tools/xmlrpc.py --auth=testclient.html factories.addScreenSize \
	testclient testfactory 1024 768
	tools/xmlrpc.py --auth=testclient.html factories.addColorDepth \
	testclient testfactory 16
	tools/xmlrpc.py --auth=testclient.html factories.addColorDepth \
	testclient testfactory 24

xmlrpc-browsers : testclient.html
	@echo Adding browsers...
#	tools/xmlrpc.py --auth=testclient.html factories.addBrowser \
#	testclient testfactory "Firefox/2.0.0.1 Gecko/200808"

testclient.html :
	wget -q http://127.0.0.1:8000/xmlrpc/auth/accounts/testclient.html

testfactory.html :
	wget -q http://127.0.0.1:8000/xmlrpc/auth/factories/testfactory.html

